
#ifndef SIM_WORLD_H
#define SIM_WORLD_H

#include <time.h>

#include <opal.h>
#include <SDL/SDL.h>

#include "Timer.h"
#include "BoxEntity.h"
#include "SphereEntity.h"
#include "CapsuleEntity.h"

#include <ode/ode.h>

#include "creature.h"
#include "bitmap.h"
#include <list>
#include <fstream>

class Simworld {

protected:
// A global list of all the drawable objects.
std::vector<opalSamples::Entity*> gEntities;

// A global pointer to the OPAL Simulator.
opal::Simulator* gSimulator;

// Used to determine when to quit.
bool gQuit;

// Used to keep track of when the simulation is paused.
bool gPaused;

// Dimensions of the ground platform.  Used when creating the ground 
// platform and when determining random positions of new objects.
opal::Vec3r gGroundDimensions;

int numFile;
unsigned int windowWidth;
unsigned int windowHeight;

bool showWindow;

int num_agents;
int num_nonagents;



//std::string worldFileName;

public:
Creature *creature;
std::vector<Creature *> agents;
std::vector<Creature *> non_agents;

bool isHumanControlAgent;
int humanControlledAgentNum;
int humanControlledSolidNum;

void init();

// Creates a window with an OpenGL context.
void setupWindow();

// Destroys the OpenGL window.
void destroyWindow();

// Gets new input from the user.  Returns false if we should quit.
bool processInput();

// Creates a random object at a semi-random location in the scene.
void createRandomObject();

/// Returns a random real value between min and max using a uniform 
/// probability distribution.
opal::real randomRealUniform(opal::real min, opal::real max);

//void applyForceAgent(opal::Vec3r v);
void save(void);

void simulate(double T);
void run(void);

~Simworld();

Simworld();//std::string file) ;

void getCreaturesFromFile();

void setShowWindow(bool show){
	showWindow = show;
}

opal::Simulator* getOpalSimulator(){ return gSimulator; }
std::vector<opalSamples::Entity*>* getEntities(){ return &gEntities; }

};

#endif


